<template>
	<view class="p-2-2 row-center">
		<text class="text-m color-main mr-1">当前小区:</text>
		<text class="text-m" :class="[curCommunity ? 'color-main font-semibold' : 'color-disable']">
			{{ curCommunity ? curCommunity.name : '未设置' }}
		</text>
		<text
			class="color-link text-m px-2-2"
			@click="changeCommunity"
			hover-class="opacity-50"
			hover-start-time="0"
			hover-stay-time="50"
		>
			{{ curCommunity ? '切换' : '设置' }}
		</text>
		<select-community ref="selIns" @select="handleSelect" isMaskClick></select-community>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import authCache from "@/uni-sdk/utils/authCache.js";

const curCommunity = ref(authCache.getCommunity());
const selIns = ref();

function changeCommunity(){	
	selIns.value.open();
}
function handleSelect(){
	curCommunity.value = authCache.getCommunity();
}
</script>

<style></style>
